<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/4/5 0005
 * Time: 下午 3:49
 */

namespace Common\Model;


use Think\Model;

class QgsSpecialAdvertstatusModel extends Model
{


    public function advert($local_id)
    {
        $advert_id =$this->where(['local_id'=>$local_id])->field('advert_id')->select();
        $count = count($advert_id);
        $returnStr='';
        for($i= 0; $i < 1; $i ++) {
            $returnStr= $advert_id [rand(0, $count-1)];
        }
        $advertData = M('qgs_special_advert a')
            ->join(C('DB_PREFIX').'qgs_special_advertstatus b on b.advert_id = a.id')
            ->field('a.id as advertId,a.name as advertName,a.image as advertImage,a.url as advertUrl')
            ->where(['b.local_id'=>$local_id,'b.advert_id'=>$returnStr['advert_id'],'b.status'=>1,'a.status'=>1])->find();
        return $advertData;
    }

}